<?php defined('SYSPATH') or die('No direct script access.') ?>
<table id="table-items" class="table table-hover">
	<tr>
		<th>#</th>
		<th>пользователь</th>
		<th>email</th>
		<th>баланс</th>
<?php
if ($role['name']=='admin' OR $role['name']=='performer')
{
?>
		<th>операции</th>
<?php
}
?>
	</tr>
<?php
foreach ($balances as &$row)
{
?>
	<tr>
		<td><?php echo $row['id'] ?></td>
		<td><?php echo HTML::anchor($controller.'/'.$action.'/'.$row['id'],$row['username']) ?></td>
		<td><?php echo $row['email'] ?></td>
		<td><?php echo !empty($row['orderid'])?HTML::anchor($controller.'/order/'.$row['orderid'],(!empty($row['sum'])?$row['sum']:0) .' <span class="rouble">Р</span>'):((!empty($row['sum'])?$row['sum']:0) .' <span class="rouble">Р</span>') ?></td>
<?php
if ($role['name']=='admin' OR $role['name']=='performer')
{
?>
		<td>
			<button type="button" class="btn btn-default btn-xs" id="balance_<?php echo $row['id'] ?>_debit" data-toggle="modal" data-target="#balance_modal"><span class="glyphicon glyphicon-plus"></span> Зачислить</button>
  			<button type="button" class="btn btn-default btn-xs" id="balance_<?php echo $row['id'] ?>_credit" data-toggle="modal" data-target="#balance_modal"><span class="glyphicon glyphicon-minus"></span> Списать</button>
  		</td>
<?php
}
?>
	</tr>
<?php
}
?>
</table>